#ifndef _DRV_SPI_STM32F411X_H_
#define _DRV_SPI_STM32F411X_H_

#include "stm32f4xx_ll_gpio.h"
#include "hal_spi.h"
#include "drv_gpio_stm32f4xx.h"

#define STM32F4XX_SPI1_MOSI_PIN1  {LL_GPIO_PIN_5, GPIOA,LL_GPIO_AF_5,LL_AHB1_GRP1_PERIPH_GPIOA}
#define STM32F4XX_SPI1_MISO_PIN1  {LL_GPIO_PIN_6, GPIOA,LL_GPIO_AF_5,LL_AHB1_GRP1_PERIPH_GPIOA}
#define STM32F4XX_SPI1_SCK_PIN1   {LL_GPIO_PIN_7, GPIOA,LL_GPIO_AF_5,LL_AHB1_GRP1_PERIPH_GPIOA}

#define STM32F4XX_SPI2_MOSI_PIN1  {LL_GPIO_PIN_13, GPIOB,LL_GPIO_AF_5,LL_AHB1_GRP1_PERIPH_GPIOB}
#define STM32F4XX_SPI2_MISO_PIN1  {LL_GPIO_PIN_14, GPIOB,LL_GPIO_AF_5,LL_AHB1_GRP1_PERIPH_GPIOB}
#define STM32F4XX_SPI2_SCK_PIN1   {LL_GPIO_PIN_15, GPIOB,LL_GPIO_AF_5,LL_AHB1_GRP1_PERIPH_GPIOB}

#define STM32F4XX_SPI1_DATA       {SPI1, LL_APB2_GRP1_PERIPH_SPI1, LL_APB2_GRP1_EnableClock, NULL, NULL, NULL, 42000000}
#define STM32F4XX_SPI2_DATA       {SPI2, LL_APB1_GRP1_PERIPH_SPI2, LL_APB1_GRP1_EnableClock, NULL, NULL, NULL, 21000000}

struct stm32f4xx_spi_adapter{
	SPI_TypeDef*             	SPIx;
    uint32_t                    clock;
	void                        (*enable_clock)(uint32_t Periphs);
	struct stm32f4xx_gpio_s     *mosi;
	struct stm32f4xx_gpio_s     *miso;
	struct stm32f4xx_gpio_s     *sck;
	uint32_t                    max_speed;
};

int stm32f4xx_spi_register(int bus_id,struct hal_spi_adapter_s *adapter,struct stm32f4xx_spi_adapter *adapter_data);

#endif
